package com.shop.cereshop.app.tencent.moderation.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;

/**
 * 视频审核回调请求
 * 参考：https://cloud.tencent.com/document/product/1265/104001
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VideoModerationCallbackRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 事件类型
     * 固定为：ReviewVideo
     */
    @JsonProperty("Event")
    private String event;

    /**
     * 视频审核任务数据
     */
    @JsonProperty("Data")
    private VideoModerationData data;

    /**
     * 视频审核任务数据内部类
     */
    @Data
    @ToString
    public static class VideoModerationData {

        @JsonProperty("TaskId")
        private String taskId;

        @JsonProperty("DataId")
        private String dataId;

        @JsonProperty("BizType")
        private String bizType;

        /**
         * 审核建议
         * Block：建议拦截
         * Review：建议人工复核
         * Pass：建议通过
         */
        @JsonProperty("Suggestion")
        private String suggestion;

        /**
         * 恶意标签
         * Normal：正常
         * Porn：色情
         * Illegal：违法
         * Abuse：谩骂
         * Ad：广告
         * Terror：暴恐
         * 等
         */
        @JsonProperty("Label")
        private String label;

        /**
         * 标签对应的评分
         * 0 - 100
         */
        @JsonProperty("Score")
        private Long score;

        @JsonProperty("CaptureCount")
        private Integer captureCount;

        /**
         * 审核状态
         * FINISHED：已完成
         * ERROR：错误
         */
        @JsonProperty("Status")
        private String status;

        /**
         * 错误码
         * 0表示成功，其他表示失败
         */
        @JsonProperty("ErrorCode")
        private Integer errorCode;

        @JsonProperty("ErrorMsg")
        private String errorMsg;

        @JsonProperty("FrameSegments")
        private List<FrameSegment> frameSegments;

        @JsonProperty("AudioSegments")
        private List<AudioSegment> audioSegments;

        @JsonProperty("TextSegments")
        private List<TextSegment> textSegments;
    }

    /**
     * 截图片段信息
     */
    @Data
    @ToString
    public static class FrameSegment {

        @JsonProperty("OffsetTime")
        private Integer offsetTime;

        @JsonProperty("Label")
        private String label;

        @JsonProperty("Score")
        private Integer score;

        @JsonProperty("Result")
        private FrameResult result;

        @JsonProperty("Url")
        private String url;
    }

    /**
     * 截图结果
     */
    @Data
    @ToString
    public static class FrameResult {

        @JsonProperty("Suggestion")
        private String suggestion;

        @JsonProperty("Label")
        private String label;

        @JsonProperty("Score")
        private Integer score;
    }

    /**
     * 音频片段信息
     */
    @Data
    @ToString
    public static class AudioSegment {

        @JsonProperty("OffsetTime")
        private Integer offsetTime;

        @JsonProperty("Duration")
        private Integer duration;

        @JsonProperty("Label")
        private String label;

        @JsonProperty("Score")
        private Integer score;

        @JsonProperty("Suggestion")
        private String suggestion;
    }

    /**
     * 文本片段信息
     */
    @Data
    @ToString
    public static class TextSegment {

        @JsonProperty("OffsetTime")
        private Integer offsetTime;

        @JsonProperty("Duration")
        private Integer duration;

        @JsonProperty("Label")
        private String label;

        @JsonProperty("Score")
        private Integer score;

        @JsonProperty("Suggestion")
        private String suggestion;

        @JsonProperty("Keywords")
        private List<String> keywords;
    }
}